﻿Imports System.Collections.Generic
Imports System.Data.SqlClient
Namespace QuanLyKhachHang
    Public Class TimKiemDAL
        Public Function TimKiem_KhuyenMai(ByVal TuNgay As Integer, ByVal DenNgay As Integer, ByVal KhachHangId As Integer, ByVal MaSanPham As String, ByVal SoLuong As Single, ByVal Type As Integer) As List(Of KhachHang)
            Try
                Dim SQLHelper As New SQLDataHelper
                Dim Reader As SqlDataReader
                SQLHelper.AddParameter("@TuNgay", TuNgay)
                SQLHelper.AddParameter("@DenNgay", DenNgay)
                SQLHelper.AddParameter("@KhachHangId", KhachHangId)
                SQLHelper.AddParameter("@MaSanPham", MaSanPham)
                SQLHelper.AddParameter("@SoLuong", SoLuong)
                SQLHelper.AddParameter("@Type", Type)
                Reader = SQLHelper.ExecuteReader("sp_TimKiem_KhuyenMai", CommandType.StoredProcedure)
                Dim item As KhachHang
                Dim list As New List(Of KhachHang)
                While (Reader.Read())
                    item = New KhachHang
                    item.STT = Reader("STT").ToString()
                    item.CodeKhachHang = Reader("CodeKhachHang").ToString()
                    item.TenKhachHang = Reader("TenKhachHang").ToString()
                    item.MaSoThue = Reader("MaSoThue").ToString()
                    item.DiaChi = Reader("DiaChi").ToString()
                    item.SoDienThoai = Reader("SoDienThoai").ToString()
                    item.SoLuong = Single.Parse(Reader("SoLuong").ToString())
                    list.Add(item)
                End While
                Return list
            Catch ex As Exception
                Throw ex
            End Try
        End Function
    End Class
End Namespace
